<?php

use yii\helpers\Url;
use yii\helpers\Html;
use website\helpers\Render;
use common\models\User;
use common\models\UserCollection;
use common\models\Employment;

$this->addCrumbs('作品管理');
$this->title = '我的作品';
?>
<style>
    #info-table {padding-top:10px;}
    #info-table .design-detail .panel {position:relative;}
    #info-table .design-detail .imager {height:255px;}
    #info-table .design-detail .title {font-size:14px;}
    #info-table .design-detail .delete-data {position:absolute;top:10px;right:10px;display:none;}
    #info-table .design-detail .panel:hover .delete-data {display:block;}
</style>

<div class="contenter">
    <?= $this->render('/user/navigator', ['active' => 'design-list']) ?>

    <div id="user-contenter">
        <div class="box-shadow pb-20px" id="sub-contenter">
            <div class="data-title"><span class="h3"><?= $this->title ?></span></div>
            <div class="clear" id="info-table">
                <div class="design-detail"><i class="icon-search"></i> 数据加载中，请稍后.</div>
            </div>
            <div class="flyer-page mt right" id="info-page"><div class="html mr-10px"></div></div>
        </div>
    </div>
</div>
<div id="render" style="display:none;">
    <?= Render::select('style', \common\models\Design::$styleSelector, null) ?>
</div>

<script src="<?= Render::static('art-template/template.js') ?>"></script>
<script src="<?= Render::static('flyer/checker.class.js') ?>"></script>
<script src="<?= Render::static('flyer/tabler.class.js') ?>"></script>
<script src="<?= Render::static('flyer/tableHandler.class.js') ?>"></script>
<script>
    $(document).ready(function() {
        // 初始化表格异步加载事件
        (new tabler).init({
            // 请求地址
            url: '<?= Url::to('@web/designer/design-list') ?>',
            // 数据渲染配置
            table: '#info-table', page: '#info-page', template: 'info-template', search: '#info-search', readyCall: true,
            // param => tabler
            afterPost: function(param) {
                tableHandler.renderCategory({ category: $('.styles'), select: '#render select[name=style]', color: false, splite: '，', default: '--' });
            }
        });
    });
</script>
<script id="info-template" type="text/html">
    {{if infos != undefined && infos.length}}
    {{each infos as info key}}
    <div class="design-detail split4 boxing transition" id="tr-{{info.id}}" data-id="{{info.id}}">
        <div class="panel">
            <div class="imager" style="background-image:url(<?= Render::upload('{{info.image}}') ?>);"></div>
            <div class="bodyer">
                <div class="title">{{info.title}}<span class="design-style styles">{{info.style}}</span></div>
                <div class="user clear">
                    <div class="photo"><img src="<?= Render::upload('{{info.designer.photo}}') ?>"></div>
                    <div class="username"><p>{{info.designer.nickname}}</p><p class="cl-red fs-12px">{{info.designer.star | star}}</p></div>
                </div>
            </div>
            <a class="delete-data flyer-button normal border-round narrow thin" href="<?= Url::to('@web/designer/design?id=') ?>{{info.id}}">编辑</a>
        </div>
    </div>
    {{/each}}
    {{else}}
    <div class="pd-10px"><i class="icon-ban-circle"></i> 您还没有发布任何作品！</div>
    {{/if}}
</script>